﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xyz.BusinessObjects;
using Xyz.DataObjects.Interfaces;

namespace Xyz.DataObjects.Entity.Dao
{
    public class EntityTicketDao : ITicketDao
    {
        public List<Ticket> GetTickets(int bookingId)
        {
            using (var context = EntityObjectFactory.CreateContext())
            {
                context.ContextOptions.LazyLoadingEnabled = false;

                var tickets = new List<Ticket>();
                var query = context.TicketEntities.Include("Passenger").Include("Flight").Include("Services").Include("FlightSeat").Include("FlightSeat.AircraftSeat").Where(x => x.BookingId == bookingId).ToList();

                //query[1].FlightSeat.AircraftSeat context.TicketEntities

                query.ForEach(x => tickets.Add(Mapper.Map(x)));

                return tickets;
            }
        }
    }
}
